package leetcode.L1000;

public class EX649 {
    public static void main(String[] args) {
        String senate = "DRRD";

        int [] cemetery = new int[senate.length()];
        int numr = 0;
        int numd = 0;
        int flag = 0;
        for(int i=0 ;i<cemetery.length;i++){
            if(senate.charAt(i)=='R'){
                numr++;
            }
            else if(senate.charAt(i)=='D'){
                numd++;
            }
        }
        while(1==1){
            for(int i=0 ;i<cemetery.length;i++ ){
                if(cemetery[i]==0){
                    if(senate.charAt(i)=='R'){
                        for(int j = i+1;j<cemetery.length;j++){
                            if(cemetery[j]==0&&senate.charAt(j)=='D'){
                                numd--;
                                cemetery[j]++;
                                flag = 1;
                                break;
                            }
                        }
                        if(flag==0) {
                            for (int j = 0; j <= i; j++) {
                                if (cemetery[j] == 0 && senate.charAt(j) == 'D') {
                                    numd--;
                                    cemetery[j]++;
                                    break;
                                }
                            }
                        }
                        flag = 0;
                    }
                    else if(senate.charAt(i)=='D'){
                        for(int j = i+1;j<cemetery.length;j++){
                            if(cemetery[j]==0&&senate.charAt(j)=='R'){
                                numr--;
                                cemetery[j]++;
                                flag = 1;
                                break;
                            }
                        }
                        if(flag==0) {


                            for (int j = 0; j <= i; j++) {
                                if (cemetery[j] == 0 && senate.charAt(j) == 'R') {
                                    numr--;
                                    cemetery[j]++;
                                    break;
                                }
                            }
                        }
                        flag = 0;
                    }
                }
                if(numr==0){
                    System.out.println("Dire");
                    break;
//                    return "Dire";
                }
                if(numd==0){
                    System.out.println("Radiant");
                    break;
//                    return "Radiant";
                }
            }
        }

        // return "";

    }
}
